const chalk = require('chalk')

const { program } = require('commander')
/**
 * options & args的参数接收顺序根据option方法定义的顺序
 */
program.name('string-util').description('CLI to some JavaScript string utilities').version('0.0.1')
program
	.command('split')
	.description('Split a string into substrings and display as an array')
	.argument('<string>', 'string to split')
	.option('-s, --separator <char>', 'separator character', ',')
	.action((str, options) => {
		console.log(chalk.red(str), options.separator, str.split(options.separator))
	})

program.parse()
